package com.atguigu.ssyx.mq.exception;

import com.atguigu.ssyx.mq.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * ClassName: GlobalExceptionHandler
 * Package: com.atguigu.ssyx.common.exception
 * Description:
 *
 * @Author Root
 * @Create 2023/8/30 17:59
 * @Version 1.0
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        e.printStackTrace();
        return Result.fail(null);
    }


    //自定义异常处理
    @ExceptionHandler(SsyxException.class)
    @ResponseBody
    public Result error(SsyxException e){
        e.printStackTrace();
        return Result.build(null,e.getCode(),e.getMessage());
    }
}